package com.xiaoniu.mc.hystrix;

import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor;

import java.lang.reflect.Method;

/**
 * @类描述：
 * @创建人：林继丰
 * @创建时间：2017/9/15 17:45
 * @版权：Copyright (c) 深圳市牛鼎丰科技有限公司-版权所有.
 */

public class HystrixCommandAdvisor extends StaticMethodMatcherPointcutAdvisor {

    public HystrixCommandAdvisor() {
        setAdvice(new HystrixCommandInterceptor());
    }

    @Override
    public boolean matches(Method method, Class<?> aClass) {
        String fullMethodName = method.getDeclaringClass().getName() + "." + method.getName();
        if (FuseContext.methodNameMapConfig.containsKey(fullMethodName)) {
            return true;
        }
        return false;
    }
}
